From 70625ce62aba43e586901d340ae81c2830d9fbc6 Mon Sep 17 00:00:00 2001 From: LarsVomMars Date: Thu, 26 Dec 2024 23:41:15 +0100 Subject: init --- src/pages/blog/[event]/index.astro | 126 +++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 src/pages/blog/[event]/index.astro (limited to 'src/pages/blog/[event]/index.astro') diff --git a/src/pages/blog/[event]/index.astro b/src/pages/blog/[event]/index.astro new file mode 100644 index 0000000..5bab8f0 --- /dev/null +++ b/src/pages/blog/[event]/index.astro @@ -0,0 +1,126 @@ +--- +import BaseHead from "../../../components/BaseHead.astro"; +import Header from "../../../components/Header.astro"; +import Footer from "../../../components/Footer.astro"; +import { SITE_TITLE, SITE_DESCRIPTION } from "../../../consts"; +import { getCollection } from "astro:content"; +import FormattedDate from "../../../components/FormattedDate.astro"; + +export async function getStaticPaths() { + const blogs = await getCollection("blog"); + const events = Object.keys( + Object.groupBy( + blogs.map((b) => ({ + id: b.id, + event: b.id.split("/").at(-2) || "", + })), + (b) => b.event + ) + ); + console.log(events); + return events.filter((e) => e).map((event) => ({ params: { event } })); +} + +const event = Astro.params.event; + +const blogs = await getCollection("blog"); + +const posts = blogs + .filter((b) => b.id.includes(event + "/")) + .sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); +--- + + + + + + + + +
+
+
+ +
+
+